/**
 * \file display.c
 * \brief Outil pour controler l'affichage de l'�cran LCD.
 * \author 
 * \version 0.6
 * \date 14 mars 2011
 *
 * Impl�mentation des fonctions aider l'affichage de l'�cran LCD.
 *
 */
#include "display.h"

#include <msp430x14x.h>

#include "../driver/lcd.h"

#include <includes.h>
#include <io.h>
#include <signal.h>
#include <iomacros.h>

extern OS_EVENT *DisplayMbox;


void afficher(char *chaine)
{
	DisplayCommand *cmd;
	cmd = malloc(sizeof(DisplayCommand));
	cmd->command = STRING;
	cmd->msg = chaine;
	OSQPost(DisplayMbox, cmd);
}

void afficherChar(char c, char ligne, char pos)
{
	DisplayCommand *cmd;
	cmd = malloc(sizeof(DisplayCommand));
	cmd->msg = malloc(3*sizeof(char));
	cmd->msg[0] = c;
	cmd->msg[1] = ligne;
	cmd->msg[2] = pos;
	cmd->command = CHAR_AT;
	OSQPost(DisplayMbox, cmd);
}

void affichage(DisplayCommand *cmd)
{
	switch (cmd->command)
	{
		case STRING:
			printDisplay(cmd->msg);
			break;
		case CHAR_AT:
			cprintDisplay(cmd->msg[0], cmd->msg[1], cmd->msg[2]);
			break;
		case CLEAR:
			clearDisplay();
			break;
		case LINE_1:
			lprintDisplay(FIRST_LINE, cmd->msg);
			break;
		case LINE_2:
			lprintDisplay(SECOND_LINE, cmd->msg);
			break;
	}
}



